package org.shilong.Utility;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * 获取用户获取  access_token值 和 expires_in值  和用户名字  微博值
 * @author Administrator
 *
 */
public class SharedPreferenceUtility {

	private static SharedPreferences SP;

	private static Editor editor = null;

	private static String[] ARR = null;

	/**
	 * 
	 * @param mContext
	 * @return
	 */
	public static String[] getPersonInfoFromSharedPreference( Context mContext ){
		ARR = null;
		ARR = new String[4];
		SP = null;

		SP = mContext.getSharedPreferences( "data", Context.MODE_PRIVATE );

		ARR[0] = SP.getString( "access_token", "null");
		ARR[1] = SP.getString( "expires_in", "null");
		ARR[2] = SP.getString( "account_name", "null");
		ARR[3] = SP.getString( "uid", "null");

		return ARR;
	}


	/**
	 * 
	 * @param access_token
	 * @param expires_in
	 * @param account_name
	 * @param account_pwd
	 * @param uid
	 * @param mContext
	 */
	public static void saveAccessTokenAndExpiresToSharedPreference( String access_token, String expires_in, String account_name, String uid, Context mContext ){

		SP = null;

		editor = null;

		SP = mContext.getSharedPreferences( "data", Context.MODE_PRIVATE );

		editor = SP.edit();

		editor.putString( "access_token", access_token );
		editor.putString( "expires_in", expires_in );
		editor.putString( "account_name", account_name );
		editor.putString( "uid", uid );

		editor.commit();

	}
}
